<template>
  <div>
    <div class="firstBox flex justifyBetween">
      <!-- 轮播图 -->
      <el-carousel height="455px" :interval="5000">
        <el-carousel-item v-for="item in bannerList" :key="item.id">
          <el-image
            style="width: 100%; height: 100%"
            :src="`${$http}${item.hotPublicize}`"
          ></el-image>
        </el-carousel-item>
      </el-carousel>
      <!-- 右侧列表 -->
      <div class="hotList">
        <div
          class="hotItem flex justifyBetween alignCenter"
          v-for="(item, index) in redlist"
          :key="item.id"
        >
          <div class="left">{{ index + 1 }}</div>
          <div class="hotItem_name" @click="changeNavTO(item.id)">
            {{ item.hotName }}
          </div>
          <div class="right">{{ item.likeNum }}</div>
        </div>
      </div>
    </div>
    <!-- 热点专区 -->
    <div class="zone">
      <div class="zone_head">热点专区</div>
      <div class="line" style="margin-top: 12px"></div>
      <div class="zoneList flex justifyAround">
        <div
          class="zoneItem flex flexColumn alignCenter"
          v-for="(item, index) in zonelist"
          :key="item.id"
        >
          <img
            :src="`${$http}${item.zonePicture}`"
            style="width: 100px; height: 100px"
          />
          <span
            style="font-size: 20px; margin-top: 16px"
            @click="pushhotSpot(item, index)"
            >{{ item.zoneName }}</span
          >
        </div>
      </div>
      <div class="line"></div>
    </div>
    <div class="threeBox flex justifyBetween">
      <!-- 热点新闻 -->
      <div v-if="newslist[0]">
        <div class="zone_head" style="padding-left: 0; margin-bottom: 16px">
          <!-- {{ newslist[0].newsTitle }} -->热点新闻
        </div>
        <img
          :src="`${$http}${newslist[0].newsGraph}`"
          style="width: 280px; height: 280px"
        />
      </div>
      <!-- 热点评论标题 -->
      <div class="newsList" v-if="newslist[0]">
        <div
          class="newsItem"
          v-for="item in newslist"
          :key="item.id"
          @click="newslistchange(item)"
        >
          <el-popover
            placement="bottom"
            title="新闻详情:"
            width="300"
            trigger="click"
            :content="titlenews"
          >
            <el-button slot="reference">
              {{ item.newsTitle }}
            </el-button>
          </el-popover>
        </div>
      </div>
      <!-- 热点评论内容 -->
      <div style="margin-left: 40px">
        <div class="pinglun_head" style="margin-bottom: 16px">推荐热点</div>
        <div class="pinglunLists">
          <div class="hotItem hotItems" v-for="item in hotlists" :key="item.id">
            <div class="fast" @click="changeNavTO(item.id)">{{ item.hotName }}</div>
            <div>{{ item.zoneName }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      bannerList: [],
      redlist: [],
      zonelist: [],
      newslist: [],
      hotlists: [],
      titlenews: "",
    };
  },
  computed: {},
  methods: {
    // 轮播图
    async getbanner() {
      let result = await this.$request.reqbanner();
      this.bannerList = result.rows;
    },
    // 热点列表
    async getredlist() {
      let result = await this.$request.reqhotlist();
      this.redlist = result.data;
    },
    // 热点专区
    async getreqzonelist() {
      let result = await this.$request.reqzonelist();
      this.zonelist = result.rows;
    },
    //
    async getreqnewslist() {
      let result = await this.$request.reqnewslist();
      this.newslist = result.rows;
    },
    async getreqhotlists() {
      let result = await this.$request.reqhotlistsnull();
      this.hotlists = result.rows;
    },
    changeNavTO(id) {
      console.log('id',id);
      this.$router.push({
        path: "/hotSpotDetail",
        query: {
          id: id,
        },
      });
    },
    pushhotSpot(item, index) {
      this.$bus.$emit("fath", item, index);
      this.$router.push({
        path: "/hotSpot",
      });
    },
    newslistchange(item) {
      this.$request.reqnews(item.id).then((res) => {
        this.titlenews = res.data.newsMessage;
      });
    },
  },
  //组件挂载完毕钩子
  mounted() {
    this.getbanner();
    this.getredlist();
    this.getreqzonelist();
    this.getreqnewslist();
    this.getreqhotlists();
    console.log(this.hotlists);
  },
};
</script>

<style lang="less">
.el-carousel {
  width: 66%;
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}

.firstBox,
.threeBox {
  width: 1200px;
  margin: 60px auto;
}

.hotList {
  width: 550px;
  height: 455px;
  background-color: #FF9999;
  padding: 0 20px;

  div {
    .left {
      width: 10%;
    }

    .hotItem_name {
      width: 70%;
      text-align: left;
      cursor: pointer;
    }

    .right {
      width: 20%;
    }
  }
}

.hotItem {
  padding: 13px 0;
  border-bottom: 1px solid rgb(188, 186, 186);
}

.hotItem_name {
  font-size: 12px;
  display: -webkit-box;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  overflow: hidden;
  -webkit-line-clamp: 1;
}

.zone {
  width: 1200px;
  margin: 0 auto;
  color: rgb(248, 248, 248);
}

.zone_head {
  /* padding-left: 100px; */
  font-size: 20px;
  font-weight: 600;
  color: rgb(252, 252, 252);

}

.line {
  width: 100%;
  height: 1px;
  background-color: rgb(254, 254, 254);
}

.zoneList {
  padding: 20px;

  img {
    width: 80px !important;
    height: 80px !important;
  }
}

.newsList {
  margin: 24px 12px;
  width: 500px;
}

.newsItem {
  border-bottom: 1px solid rgb(188, 186, 186);
  font-size: 16px;
  padding: 16px 0;
  text-align: center;
}

.pinglunLists {
  width: 400px;
  background-color: #5b5b5b;
  color: rgb(252, 252, 252);
  opacity: 0.8;

  .hotItem {
    padding: 0;
      height: 40px;
      margin-bottom: 20px;

    .fast {
      width: 60%;
      // overflow: hidden;
      // text-overflow: ellipsis;
      // display: -webkit-box;
      // -webkit-line-clamp: 1;
      // word-break: break-all;
      // -webkit-box-orient: vertical;
      overflow:hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      -o-text-overflow:ellipsis;
    }
    div:last-child {
      width: 40%;
      text-align: right;
    }
  }
}

.pinglun_head {
  font-size: 20px;
  font-weight: 600;
  color: rgb(255, 248, 248);
}

.hotItems {
  display: flex !important;
  justify-content: space-between !important;
}
</style>
